#ifndef NODE_CONTAINER_H
#define NODE_CONTAINER_H

#include "llvm/Module.h"
#include "llvm/IRBuilder.h"
#include "Node.h"

//Notes:
//Nodes are "promoted" to the emittable list if all of their sinks are assigned.
//propagateValues assigns source values to sinks


class NodeContainer {
 public:

  NodeContainer();
  virtual ~NodeContainer();

  //Nodes call this method on their parents to promote themselves
  void promoteChild(Node* node);
  
  //inherited classes should call addNode in their implementation
  virtual void add(Node* child)=0;
  
 protected:
  
  //children helpers
  void addNode(Node* child);
  void processNodes (llvm::IRBuilder<> *builder);
  
  //Ownership
  std::list<Node*> children;
  
  //non-ownership (they're really all children anyway)
  std::list<Node*> emittable;
  
};

#endif
